package com.xd.core.business.controller;


import com.xd.core.business.dto.EditInsurerDto;
import com.xd.core.business.dto.InsurerAccountDto;
import com.xd.core.business.dto.InsurerDto;
import com.xd.core.business.service.IInsuranceCompanyInfoService;
import com.xd.core.business.vo.InsurerListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 投保公司信息 前端控制器
 * </p>
 *
 * @author Zch
 * @since 2025-06-18
 */
@RestController
@RequestMapping("/insurance-company-info")
@Api(tags = "投保公司管理")
@Slf4j
public class InsuranceCompanyInfoController {

    @Autowired
    private IInsuranceCompanyInfoService infoService;

    @ApiOperation("新增资方投保公司")
    @PostMapping("/addInsurer")
    public void addInsurer(@RequestBody InsurerDto insurerDto) {
        infoService.addInsurer(insurerDto);
        log.info("新增资方投保公司成功,参数{}", insurerDto);
    }

    @ApiOperation("资方投保公司列表")
    @GetMapping("/insurerList/{companyId}")
    public List<InsurerListVo> insurerList(@PathVariable Integer companyId) {
        return infoService.insurerList(companyId);
    }

    @ApiOperation("资方投保公司编辑回显")
    @GetMapping("/insurerOne/{insurerId}")
    public InsurerListVo insurerOne(@PathVariable Integer insurerId) {
        return infoService.insurerOne(insurerId);
    }

    @ApiOperation("编辑资方投保公司")
    @PutMapping("/editInsurer")
    public void editInsurer(@RequestBody EditInsurerDto editInsurerDto) {
        infoService.editInsurer(editInsurerDto);
        log.info("修改资方投保公司成功,参数{}", editInsurerDto);
    }

    @ApiOperation("查看投保公司账户信息")
    @GetMapping("/insurerAccount/{insurerId}")
    public InsurerAccountDto insurerAccount(@PathVariable Integer insurerId) {
        return infoService.insurerAccount(insurerId);
    }

    @ApiOperation("编辑资方投保公司启用状态")
    @PutMapping("/editInsurerEnable")
    public void editInsurer(Integer isEnable, Integer insurerId) {
        infoService.editInsurerEnable(isEnable,insurerId);
    }
}
